home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 90 / CD Actual 90.iso / Software3D / K-3D / k3d-0.4.2.1 / shaders / k3d_arealight.sl < prev    next >
Encoding:
Text File  |  2004-07-23  |  868 b   |  32 lines

  1. /*
  2.  * arealight.sl - light source shader appropriate for an area light source.
  3.  *
  4.  * DESCRIPTION:
  5.  *   Makes light with cosine falloff from the normal of the light source
  6.  *   surface.  This is perfect for using with area light sources.
  7.  *
  8.  * PARAMETERS
  9.  *   intensity, lightcolor - same meanings as pointlight
  10.  *
  11.  */
  12.  
  13. light k3d_arealight(float intensity = 1; color lightcolor = 1;)
  14. {
  15. #ifdef BMRT
  16.   illuminate(P, N, 1.5707963 /* PI/2 */ )
  17.   {
  18.     Cl = (intensity / (L.L)) * lightcolor;
  19.   }
  20. #else
  21.   /* This is so if we use one of these lights in PRMan, it will
  22.    * approximately work for a flat light source whose normal points
  23.    * toward local +z.
  24.    */
  25.   vector Nl = normalize(vector "shader"(0, 0, 1));
  26.   illuminate(point "shader"(0, 0, 0), Nl, PI / 2)
  27.   {
  28.     Cl = (intensity * (Nl.normalize(L) / (L.L)) * lightcolor);
  29.   }
  30. #endif
  31. }
  32.